export default {
    ADD_ITEM(state, product) {
      const existingItem = state.cartItems.find(item => item.id === product.id)
      if (existingItem) {
        existingItem.quantity++
      } else {
        state.cartItems.push({ ...product, quantity: 1 })
      }
    },
    
    REMOVE_ITEM(state, itemId) {
      const index = state.cartItems.findIndex(item => item.id === itemId)
      if (index !== -1) {
        state.cartItems.splice(index, 1)
      }
    },
    
    INCREMENT_QUANTITY(state, itemId) {
      const item = state.cartItems.find(item => item.id === itemId)
      if (item) {
        item.quantity++
      }
    },
    
    DECREMENT_QUANTITY(state, itemId) {
      const item = state.cartItems.find(item => item.id === itemId)
      if (item && item.quantity > 1) {
        item.quantity--
      }
    }
  }